import java.util.ArrayList;

/*Main server class, this is used to start each server node.
if no arg is specified it runs as a simulation on one machine,
otherwise an index needs to be specified indicating the server's
position in the machines.txt file*/

public class ServerMain {

	public static void main(String[] args) {
		
		String filename = "machines.txt";
		
		//we are running in simulation mode
		if(args.length == 0) {
			ArrayList<MachineData> machines = MachineData.getList(filename);
			ArrayList<Server> servers = new ArrayList<Server>();
			
			int N = machines.size();
			
			for(int i = 0; i < N; i++) {
				servers.add(new Server(i, machines));
				//servers.get(i).start();
			}
		}
		//we are running for real
		else {
			ArrayList<MachineData> machines = MachineData.getList(filename);
			Server s= new Server(Integer.parseInt(args[0]), machines);
		}
	}
	
}
